<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑任务攻略</title>
</head>
<body>
<script type="text/html" id="form">
    <input type="hidden" name="id" value="{{ d.id }}" />
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">季节</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="season"
                             data-sourceType="route"
                             data-source="/admin.sky.season/season"
                             data-textField="sub_category"
                             data-valueField="sub_category"
                             data-radio="true"
                             data-selected="{{=d.season}}"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">标题名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="navBarTitle" lay-verify="required" value="{{d.navBarTitle}}" autocomplete="off" placeholder="请输入标题名称" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">索引标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="taskIndexTitle" lay-verify="required" value="{{d.taskIndexTitle}}" autocomplete="off" placeholder="请输入标题名称" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">关于1</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入季节任务描述" name="description" id="LAY_demo" lay-verify="content"></textarea>
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务1索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index1" value="{{d.index1}}" lay-verify="required" autocomplete="off" placeholder="请输入任务1索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务1标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title1" value="{{d.title1}}" lay-verify="required" autocomplete="off" placeholder="请输入任务1标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务1</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content1"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content1 }}"
                             data-uploadedId="{{ d.content1 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务2索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index2" value="{{d.index2}}" autocomplete="off" placeholder="请输入任务2索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务2标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title2" value="{{d.title2}}" autocomplete="off" placeholder="请输入任务2标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务2</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content2"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content2 }}"
                             data-uploadedId="{{ d.content2 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务3索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index3" value="{{d.index3}}" autocomplete="off" placeholder="请输入任务3索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务3标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title3" value="{{d.title3}}" autocomplete="off" placeholder="请输入任务3标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务3</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content3"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content3 }}"
                             data-uploadedId="{{ d.content3 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务4索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index4" value="{{d.index4}}" autocomplete="off" placeholder="请输入任务4索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务4标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title4" value="{{d.title4}}" autocomplete="off" placeholder="请输入任务4标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务4</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content4"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content4 }}"
                             data-uploadedId="{{ d.content4 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务5索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index5" value="{{d.index5}}" autocomplete="off" placeholder="请输入任务5索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务5标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title5" value="{{d.title5}}" autocomplete="off" placeholder="请输入任务5标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务5</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content5"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content5 }}"
                             data-uploadedId="{{ d.content5 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务6索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index6" value="{{d.index6}}" autocomplete="off" placeholder="请输入任务6索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务6标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title6" value="{{d.title6}}" autocomplete="off" placeholder="请输入任务6标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务6</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content6"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content6 }}"
                             data-uploadedId="{{ d.content6 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>



                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务7索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index7" value="{{d.index7}}" autocomplete="off" placeholder="请输入任务7索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务7标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title7" value="{{d.title7}}" autocomplete="off" placeholder="请输入任务7标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务7</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content7"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content7 }}"
                             data-uploadedId="{{ d.content7 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>



                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务8索引</label>
                    <div class="layui-input-block">
                        <input type="text" name="index8" value="{{d.index8}}" autocomplete="off" placeholder="请输入任务8索引" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item" style="width: 40%">
                    <label class="layui-form-label">任务8标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title8" value="{{d.title8}}" autocomplete="off" placeholder="请输入任务8标题" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">任务8</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="content8"
                             data-accept="image"
                             data-type="ali-oss"
                             data-multi="true"
                             data-radio="false"
                             data-uploaded="{{ d.content8 }}"
                             data-uploadedId="{{ d.content8 }}"
                             data-showChoiceBtn="false"
                        ></div>
                    </div>
                </div>

            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="laytp-form">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    layui.use(['laytp','xmSelect','layedit','form'],function(){
        let $ = layui.jquery;
        let form = layui.form;
        var layedit = layui.layedit;

        layedit.set({
            uploadImage:{
                url:"/admin.common/editUpload"
                ,type:''//默认post
            },
            uploadVideo:{
                url:"/admin.common/editUpload"
                ,type:''//默认post
            }
        })

        //获取参数ID
        var id = facade.getUrlParam('id');
        if(!id){
            facade.error('参数ID不能为空');
            return false;
        }

        //获取数据，渲染到对应的节点上
        facade.ajax({
            route: "/admin.sky.strategy/info",
            data: {id: id},
            successAlert: false,
            showLoading: true
        }).done(function(res){
            if(res.code === 0){
                layui.laytpl($("#form").html()).render(res.data,function(string){
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });

                var index = layedit.build('LAY_demo', {
                    tool: [
                        'strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right','|', 'image','video'
                    ],
                    height: 500,
                });

                form.verify({
                    content: function(value) {
                        return layedit.sync(index);
                    },
                });

                layedit.setContent(index,res.data.description);
            }
        });

        form.on('submit(laytp-form)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.sky.strategy/edit',
                data:data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>